package com.websecondhand.exception;

import com.websecondhand.Constant;
import com.websecondhand.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
    /*
        全局处理异常
     */
    @ExceptionHandler(WebProjectException.class)
    @ResponseBody
    public R error(WebProjectException e)
    {
        return R.error().changeMessage(e.getMessage()).changeCode(Constant.ServerError);
    }
}
